package com.becca.cake.model.users;

import java.io.Serializable;
import java.util.Date;

import org.apache.commons.lang.StringUtils;

import com.becca.cake.core.exception.ServiceException;
import com.becca.cake.util.StringUtil;

/**
 * 我的优惠券
 * @copyright  尊星(上海)信息科技有限公司
 * @author hejinguo
 * @date 2016年4月10日 上午3:58:44
 */
public class UserCouponModel implements Serializable {
    /**  */
    private static final long   serialVersionUID       = 4537163368493901368L;
    /**红包类型不能为空*/
    public static final String  COUPON_TYPE_NULL       = "红包类型不能为空";
    /**手机号不能为空*/
    public static final String  COUPON_MOBILENO_NULL   = "手机号不能为空";
    /**优惠金额不能为空*/
    public static final String  COUPON_MONEY_NULL      = "优惠金额不能为空";

    /**优惠券状态(0:未使用)*/
    public static final Byte    COUPON_STATUS_NO_USER  = 0;

    /**优惠券状态(1:已使用)*/
    public static final Byte    COUPON_STATUS_USER     = 1;

    /**来源类型(2:赠送红包)*/
    public static final Byte    COUPON_PARTTOOK_SOURCE = 2;

    /**是否使用有效期(1:是)*/
    public static final Integer COUPON_USER_END_DATE   = 1;

    /**请选择是否使用有效期*/
    public static final String  IS_USER_DATE_NULL      = "请选择是否使用有效期";

    /**有效天数不能为空*/
    public static final String  USE_DATE_NULL          = "有效天数不能为空";

    private Integer             id;
    /**优惠券分享来源ID*/
    private Integer             partookCouponId;
    /**优惠券分享来源*/
    private Byte                partookCouponSource;
    /**领取用户ID*/
    private Integer             userId;
    /**领取用户ID*/
    private String              userName;
    /**优惠券金额*/
    private Double              couponMoney;
    /**用户手机号*/
    private String              userMobileNo;
    /**优惠券使用开始时间*/
    private Date                userStartDate;
    /**优惠券使用截止时间*/
    private Date                userEndDate;
    /**领取时间*/
    private Date                doleDate;
    /**优惠券状态(0:未使用 1:已使用 2:已过期)*/
    private Byte                couponStatus;
    /**优惠券使用订单ID(在使用后回填)*/
    private Integer             useOrderId;
    /**创建时间*/
    private Date                createdDate;
    /**创建人*/
    private String              createdName;
    /**修改时间*/
    private Date                updatedDate;
    /**修改人*/
    private String              updatedName;
    /**优惠券张数*/
    private String              couponNumber;

    /**
     * 转换请求参数信息
     * @return
     */
    public static String transCouponType(Integer couponType) {
        if (couponType == 0) {
            return "0";
        } else if (couponType == 1) {
            return "1,2";
        }
        return "";
    }

    /**
     * 校验手机号
     * @param mobileNo
     */
    public static void validMobileNoNull(String mobileNo) {
        if (StringUtil.isEmpty(mobileNo)) {
            throw new ServiceException(UserCouponModel.COUPON_MOBILENO_NULL);
        }

    }

    // 赠送红包时校验
    public static void validInsetUserCoupon(UserCouponModel userCouponModel, Integer isUseDate) {
        if (StringUtils.isEmpty(userCouponModel.getUserMobileNo())) {
            throw new ServiceException(UserCouponModel.COUPON_MOBILENO_NULL);
        }
        if (userCouponModel.getCouponMoney() == null) {
            throw new ServiceException(UserCouponModel.COUPON_MONEY_NULL);
        }
        if (isUseDate == null) {
            throw new ServiceException(UserCouponModel.IS_USER_DATE_NULL);
        }
    }

    // 赠送红包时校验
    public static void validInsetAllUserCoupon(UserCouponModel userCouponModel, Integer isUseDate) {
        if (userCouponModel.getCouponMoney() == null) {
            throw new ServiceException(UserCouponModel.COUPON_MONEY_NULL);
        }
        if (isUseDate == null) {
            throw new ServiceException(UserCouponModel.IS_USER_DATE_NULL);
        }
    }

    public Byte getPartookCouponSource() {
        return partookCouponSource;
    }

    public void setPartookCouponSource(Byte partookCouponSource) {
        this.partookCouponSource = partookCouponSource;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getPartookCouponId() {
        return partookCouponId;
    }

    public void setPartookCouponId(Integer partookCouponId) {
        this.partookCouponId = partookCouponId;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public Double getCouponMoney() {
        return couponMoney;
    }

    public void setCouponMoney(Double couponMoney) {
        this.couponMoney = couponMoney;
    }

    public Date getUserStartDate() {
        return userStartDate;
    }

    public void setUserStartDate(Date userStartDate) {
        this.userStartDate = userStartDate;
    }

    public Date getUserEndDate() {
        return userEndDate;
    }

    public void setUserEndDate(Date userEndDate) {
        this.userEndDate = userEndDate;
    }

    public Date getDoleDate() {
        return doleDate;
    }

    public void setDoleDate(Date doleDate) {
        this.doleDate = doleDate;
    }

    public Byte getCouponStatus() {
        return couponStatus;
    }

    public void setCouponStatus(Byte couponStatus) {
        this.couponStatus = couponStatus;
    }

    public Integer getUseOrderId() {
        return useOrderId;
    }

    public void setUseOrderId(Integer useOrderId) {
        this.useOrderId = useOrderId;
    }

    public Date getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }

    public String getCreatedName() {
        return createdName;
    }

    public void setCreatedName(String createdName) {
        this.createdName = createdName;
    }

    public Date getUpdatedDate() {
        return updatedDate;
    }

    public void setUpdatedDate(Date updatedDate) {
        this.updatedDate = updatedDate;
    }

    public String getUpdatedName() {
        return updatedName;
    }

    public void setUpdatedName(String updatedName) {
        this.updatedName = updatedName;
    }

    public String getUserMobileNo() {
        return userMobileNo;
    }

    public void setUserMobileNo(String userMobileNo) {
        this.userMobileNo = userMobileNo;
    }
    
    public String getCouponNumber()
	{
		return couponNumber;
	}

	public void setCouponNumber(String couponNumber)
	{
		this.couponNumber = couponNumber;
	}

	@Override
    public String toString() {
        return "UserCouponDO [id=" + id + ", partookCouponId=" + partookCouponId + ", userId="
               + userId + ", couponMoney=" + couponMoney + ", userStartDate=" + userStartDate
               + ", userEndDate=" + userEndDate + ", doleDate=" + doleDate + ", couponStatus="
               + couponStatus + ", useOrderId=" + useOrderId + ", createdDate=" + createdDate
               + ", createdName=" + createdName + ", updatedDate=" + updatedDate + ", updatedName="
               + updatedName + ", couponNumber=" + couponNumber + ", userMobileNo=" + userMobileNo + "]";
    }

}
